﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Yottamud_2013_v3_Main.Game_Files;

namespace Yottamud_2013_v3_Main
{
    class ResourceCollector
    {
        public enum GameResourceType
        {
            Spell,
            Item,
            NPC,
            Room
        }

        public static ResourceTypes.RaceType[] LoadRaceFromDB(string iDBFile)
        {
            DatabaseUtility dbUtil = new DatabaseUtility(iDBFile);

            DataTable raceTable = dbUtil.QueryDataBaseForTableInformation("Races");

            ResourceTypes.RaceType[] raceInformation = new ResourceTypes.RaceType[raceTable.Rows.Count];


            for (int i = 0; i < raceTable.Rows.Count; i++)
            {

                raceInformation[i] = new ResourceTypes.RaceType();
                raceInformation[i].RaceNumber = int.Parse(raceTable.Rows[i]["Number"].ToString());
                raceInformation[i].RaceName = raceTable.Rows[i]["Name"].ToString();
                raceInformation[i].MinIntellect = int.Parse(raceTable.Rows[i]["mINT"].ToString());
                raceInformation[i].MinWillpower = int.Parse(raceTable.Rows[i]["mWIL"].ToString());
                raceInformation[i].MinCharm = int.Parse(raceTable.Rows[i]["mCHM"].ToString());
                raceInformation[i].MinStrength = int.Parse(raceTable.Rows[i]["mSTR"].ToString());
                raceInformation[i].MinAgility = int.Parse(raceTable.Rows[i]["mAGL"].ToString());
                raceInformation[i].MinHealth = int.Parse(raceTable.Rows[i]["mHEA"].ToString());
                raceInformation[i].MaxIntellect = int.Parse(raceTable.Rows[i]["xINT"].ToString());
                raceInformation[i].MaxWillpower = int.Parse(raceTable.Rows[i]["xWIL"].ToString());
                raceInformation[i].MaxCharm = int.Parse(raceTable.Rows[i]["xCHM"].ToString());
                raceInformation[i].MaxStrength = int.Parse(raceTable.Rows[i]["xSTR"].ToString());
                raceInformation[i].MaxAgility = int.Parse(raceTable.Rows[i]["xAGL"].ToString());
                raceInformation[i].MaxHealth = int.Parse(raceTable.Rows[i]["xHEA"].ToString());
                raceInformation[i].ExpTable = int.Parse(raceTable.Rows[i]["ExpTable"].ToString());
                raceInformation[i].BaseCP = int.Parse(raceTable.Rows[i]["BaseCP"].ToString());

                for (int a = 0; a < 10; a++)
                {
                    ResourceTypes.AbilityType ability = new ResourceTypes.AbilityType();

                    ability.AbilityID = int.Parse(raceTable.Rows[i]["Abil-" + a].ToString());
                    ability.AbilityValue = int.Parse(raceTable.Rows[i]["AbilVal-" + a].ToString());
                    ability.AbilityName = GameResources.FindAbility(ability.AbilityID);

                    if (ability.AbilityID != 0)
                    {
                        raceInformation[i].RaceAbilityList.Add(ability);
                    }
                }

            }

            return raceInformation;
        }

        public static ResourceTypes.ClassType[] LoadClassFromDB(string iDBFile)
        {
            DatabaseUtility dbUtil = new DatabaseUtility(iDBFile);

            DataTable classTable = dbUtil.QueryDataBaseForTableInformation("Classes");

            ResourceTypes.ClassType[] classInformation = new ResourceTypes.ClassType[classTable.Rows.Count];


            for (int i = 0; i < classInformation.Length; i++)
            {
                classInformation[i] = new ResourceTypes.ClassType();
                classInformation[i].ClassNumber = int.Parse(classTable.Rows[i]["Number"].ToString());
                classInformation[i].ClassName = classTable.Rows[i]["Name"].ToString();
                classInformation[i].CombatLevel = int.Parse(classTable.Rows[i]["CombatLVL"].ToString());
                classInformation[i].MinHits = int.Parse(classTable.Rows[i]["MinHits"].ToString());
                classInformation[i].MaxHits = int.Parse(classTable.Rows[i]["MaxHits"].ToString());
                classInformation[i].MageryLevel = int.Parse(classTable.Rows[i]["MageryType"].ToString());
                classInformation[i].MageryLevel = int.Parse(classTable.Rows[i]["MageryLVL"].ToString());
                classInformation[i].ArmourType = int.Parse(classTable.Rows[i]["ArmourType"].ToString());
                classInformation[i].ExpTable = int.Parse(classTable.Rows[i]["ExpTable"].ToString());

                for (int a = 0; a < 10; a++)
                {
                    ResourceTypes.AbilityType ability = new ResourceTypes.AbilityType();

                    ability.AbilityID = int.Parse(classTable.Rows[i]["Abil-" + a].ToString());
                    ability.AbilityValue = int.Parse(classTable.Rows[i]["AbilVal-" + a].ToString());
                    ability.AbilityName = GameResources.FindAbility(ability.AbilityID);

                    if (ability.AbilityID != 0)
                    {
                        classInformation[i].ClassAbilityList.Add(ability);
                    }

                }

            }

            return classInformation;
        }

        public static ResourceTypes.ShopType[] LoadShopFromDB(string iDBFile)
        {
            DatabaseUtility dbUtil = new DatabaseUtility(iDBFile);

            DataTable shopTable = dbUtil.QueryDataBaseForTableInformation("Shops");

            ResourceTypes.ShopType[] shopInformation = new ResourceTypes.ShopType[shopTable.Rows.Count];

            for (int i = 0; i < shopInformation.Length; i++)
            {
                shopInformation[i] = new ResourceTypes.ShopType();
                shopInformation[i].ShopNumber = int.Parse(shopTable.Rows[i]["Number"].ToString());
                shopInformation[i].ShopName = shopTable.Rows[i]["Name"].ToString();
                shopInformation[i].MinLevel = int.Parse(shopTable.Rows[i]["MinLVL"].ToString());
                shopInformation[i].MaxLevel = int.Parse(shopTable.Rows[i]["MaxLVL"].ToString());
                shopInformation[i].Markup = int.Parse(shopTable.Rows[i]["Markup%"].ToString());
                shopInformation[i].ClassRestriction = int.Parse(shopTable.Rows[i]["ClassRest"].ToString());

                shopInformation[i].Item_0 = int.Parse(shopTable.Rows[i]["Item-0"].ToString());

            

                shopInformation[i].Max_0 = int.Parse(shopTable.Rows[i]["Max-0"].ToString());
                shopInformation[i].Time_0 = int.Parse(shopTable.Rows[i]["Time-0"].ToString());
                shopInformation[i].Amount_0 = int.Parse(shopTable.Rows[i]["Amount-0"].ToString());
                shopInformation[i].Item_1 = int.Parse(shopTable.Rows[i]["Item-1"].ToString());
                shopInformation[i].Max_1 = int.Parse(shopTable.Rows[i]["Max-1"].ToString());
                shopInformation[i].Time_1 = int.Parse(shopTable.Rows[i]["Time-1"].ToString());
                shopInformation[i].Amount_1 = int.Parse(shopTable.Rows[i]["Amount-1"].ToString());
                shopInformation[i].Item_2 = int.Parse(shopTable.Rows[i]["Item-2"].ToString());
                shopInformation[i].Max_2 = int.Parse(shopTable.Rows[i]["Max-2"].ToString());
                shopInformation[i].Time_2 = int.Parse(shopTable.Rows[i]["Time-2"].ToString());
                shopInformation[i].Amount_2 = int.Parse(shopTable.Rows[i]["Amount-2"].ToString());
                shopInformation[i].Item_3 = int.Parse(shopTable.Rows[i]["Item-3"].ToString());
                shopInformation[i].Max_3 = int.Parse(shopTable.Rows[i]["Max-3"].ToString());
                shopInformation[i].Time_3 = int.Parse(shopTable.Rows[i]["Time-3"].ToString());
                shopInformation[i].Amount_3 = int.Parse(shopTable.Rows[i]["Amount-3"].ToString());
                shopInformation[i].Item_4 = int.Parse(shopTable.Rows[i]["Item-4"].ToString());
                shopInformation[i].Max_4 = int.Parse(shopTable.Rows[i]["Max-4"].ToString());
                shopInformation[i].Time_4 = int.Parse(shopTable.Rows[i]["Time-4"].ToString());
                shopInformation[i].Amount_4 = int.Parse(shopTable.Rows[i]["Amount-4"].ToString());
                shopInformation[i].Item_5 = int.Parse(shopTable.Rows[i]["Item-5"].ToString());
                shopInformation[i].Max_5 = int.Parse(shopTable.Rows[i]["Max-5"].ToString());
                shopInformation[i].Time_5 = int.Parse(shopTable.Rows[i]["Time-5"].ToString());
                shopInformation[i].Amount_5 = int.Parse(shopTable.Rows[i]["Amount-5"].ToString());
                shopInformation[i].Item_6 = int.Parse(shopTable.Rows[i]["Item-6"].ToString());
                shopInformation[i].Max_6 = int.Parse(shopTable.Rows[i]["Max-6"].ToString());
                shopInformation[i].Time_6 = int.Parse(shopTable.Rows[i]["Time-6"].ToString());
                shopInformation[i].Amount_6 = int.Parse(shopTable.Rows[i]["Amount-6"].ToString());
                shopInformation[i].Item_7 = int.Parse(shopTable.Rows[i]["Item-7"].ToString());
                shopInformation[i].Max_7 = int.Parse(shopTable.Rows[i]["Max-7"].ToString());
                shopInformation[i].Time_7 = int.Parse(shopTable.Rows[i]["Time-7"].ToString());
                shopInformation[i].Amount_7 = int.Parse(shopTable.Rows[i]["Amount-7"].ToString());
                shopInformation[i].Item_8 = int.Parse(shopTable.Rows[i]["Item-8"].ToString());
                shopInformation[i].Max_8 = int.Parse(shopTable.Rows[i]["Max-8"].ToString());
                shopInformation[i].Time_8 = int.Parse(shopTable.Rows[i]["Time-8"].ToString());
                shopInformation[i].Amount_8 = int.Parse(shopTable.Rows[i]["Amount-8"].ToString());
                shopInformation[i].Item_9 = int.Parse(shopTable.Rows[i]["Item-9"].ToString());
                shopInformation[i].Max_9 = int.Parse(shopTable.Rows[i]["Max-9"].ToString());
                shopInformation[i].Time_9 = int.Parse(shopTable.Rows[i]["Time-9"].ToString());
                shopInformation[i].Amount_9 = int.Parse(shopTable.Rows[i]["Amount-9"].ToString());
                shopInformation[i].Item_10 = int.Parse(shopTable.Rows[i]["Item-10"].ToString());
                shopInformation[i].Max_10 = int.Parse(shopTable.Rows[i]["Max-10"].ToString());
                shopInformation[i].Time_10 = int.Parse(shopTable.Rows[i]["Time-10"].ToString());
                shopInformation[i].Amount_10 = int.Parse(shopTable.Rows[i]["Amount-10"].ToString());
                shopInformation[i].Item_11 = int.Parse(shopTable.Rows[i]["Item-11"].ToString());
                shopInformation[i].Max_11 = int.Parse(shopTable.Rows[i]["Max-11"].ToString());
                shopInformation[i].Time_11 = int.Parse(shopTable.Rows[i]["Time-11"].ToString());
                shopInformation[i].Amount_11 = int.Parse(shopTable.Rows[i]["Amount-11"].ToString());


                shopInformation[i].Item_12 = int.Parse(shopTable.Rows[i]["Item-12"].ToString());
                shopInformation[i].Max_12 = int.Parse(shopTable.Rows[i]["Max-12"].ToString());
                shopInformation[i].Time_12 = int.Parse(shopTable.Rows[i]["Time-12"].ToString());
                shopInformation[i].Amount_12 = int.Parse(shopTable.Rows[i]["Amount-12"].ToString());

                shopInformation[i].Item_13 = int.Parse(shopTable.Rows[i]["Item-13"].ToString());
                shopInformation[i].Max_13 = int.Parse(shopTable.Rows[i]["Max-13"].ToString());
                shopInformation[i].Time_13 = int.Parse(shopTable.Rows[i]["Time-13"].ToString());
                shopInformation[i].Amount_13 = int.Parse(shopTable.Rows[i]["Amount-13"].ToString());

                shopInformation[i].Item_14 = int.Parse(shopTable.Rows[i]["Item-14"].ToString());
                shopInformation[i].Max_14 = int.Parse(shopTable.Rows[i]["Max-14"].ToString());
                shopInformation[i].Time_14 = int.Parse(shopTable.Rows[i]["Time-14"].ToString());
                shopInformation[i].Amount_14 = int.Parse(shopTable.Rows[i]["Amount-14"].ToString());

                shopInformation[i].Item_15 = int.Parse(shopTable.Rows[i]["Item-15"].ToString());
                shopInformation[i].Max_15 = int.Parse(shopTable.Rows[i]["Max-15"].ToString());
                shopInformation[i].Time_15 = int.Parse(shopTable.Rows[i]["Time-15"].ToString());
                shopInformation[i].Amount_15 = int.Parse(shopTable.Rows[i]["Amount-15"].ToString());

                shopInformation[i].Item_16 = int.Parse(shopTable.Rows[i]["Item-16"].ToString());
                shopInformation[i].Max_16 = int.Parse(shopTable.Rows[i]["Max-16"].ToString());
                shopInformation[i].Time_16 = int.Parse(shopTable.Rows[i]["Time-16"].ToString());
                shopInformation[i].Amount_16 = int.Parse(shopTable.Rows[i]["Amount-16"].ToString());

                shopInformation[i].Item_17 = int.Parse(shopTable.Rows[i]["Item-17"].ToString());
                shopInformation[i].Max_17 = int.Parse(shopTable.Rows[i]["Max-17"].ToString());
                shopInformation[i].Time_17 = int.Parse(shopTable.Rows[i]["Time-17"].ToString());
                shopInformation[i].Amount_17 = int.Parse(shopTable.Rows[i]["Amount-17"].ToString());

                shopInformation[i].Item_18 = int.Parse(shopTable.Rows[i]["Item-18"].ToString());
                shopInformation[i].Max_18 = int.Parse(shopTable.Rows[i]["Max-18"].ToString());
                shopInformation[i].Time_18 = int.Parse(shopTable.Rows[i]["Time-18"].ToString());
                shopInformation[i].Amount_18 = int.Parse(shopTable.Rows[i]["Amount-18"].ToString());

                shopInformation[i].Item_19 = int.Parse(shopTable.Rows[i]["Item-19"].ToString());
                shopInformation[i].Max_19 = int.Parse(shopTable.Rows[i]["Max-19"].ToString());
                shopInformation[i].Time_19 = int.Parse(shopTable.Rows[i]["Time-19"].ToString());
                shopInformation[i].Amount_19 = int.Parse(shopTable.Rows[i]["Amount-19"].ToString());

                shopInformation[i].InGame = int.Parse(shopTable.Rows[i]["In Game"].ToString());
                shopInformation[i].AssignedTo = shopTable.Rows[i]["Assigned To"].ToString();


                if (shopInformation[i].Item_0 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_0));
                }
                if (shopInformation[i].Item_1 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_1));
                }
                if (shopInformation[i].Item_2 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_2));
                }
                if (shopInformation[i].Item_3 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_3));
                }

                if (shopInformation[i].Item_4 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_4));
                }

                if (shopInformation[i].Item_5 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_5));
                }


                if (shopInformation[i].Item_6 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_6));
                }


                if (shopInformation[i].Item_7 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_7));
                }


                if (shopInformation[i].Item_8 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_8));
                }

                if (shopInformation[i].Item_9 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_9));
                }
                if (shopInformation[i].Item_10 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_10));
                }
                if (shopInformation[i].Item_11 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_11));
                }
                if (shopInformation[i].Item_12 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_12));
                }
                if (shopInformation[i].Item_13 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_13));
                }

                if (shopInformation[i].Item_14 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_14));
                }
                if (shopInformation[i].Item_15 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_15));
                }
                if (shopInformation[i].Item_16 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_16));
                }
                if (shopInformation[i].Item_17 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_17));
                }
                if (shopInformation[i].Item_18 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_18));
                }
                if (shopInformation[i].Item_19 != 0)
                {
                    shopInformation[i].ItemList.Add(GameResources.FindItem(shopInformation[i].Item_19));
                }

            }

            return shopInformation;
        }

        public static ResourceTypes.SpellType[] LoadSpellFromDB(string iDBFile, bool write)
        {
            DatabaseUtility dbUtil = new DatabaseUtility(iDBFile);

            DataTable spellsTable = dbUtil.QueryDataBaseForTableInformation("Spells");

            ResourceTypes.SpellType[] spellInformation = new ResourceTypes.SpellType[spellsTable.Rows.Count];

            for (int i = 0; i < spellInformation.Length; i++)
            {

                spellInformation[i] = new ResourceTypes.SpellType();
                spellInformation[i].Number = int.Parse(spellsTable.Rows[i]["Number"].ToString());
                spellInformation[i].Name = spellsTable.Rows[i]["Name"].ToString();
                spellInformation[i].Short = spellsTable.Rows[i]["Short"].ToString();
                spellInformation[i].ReqLevel = int.Parse(spellsTable.Rows[i]["ReqLevel"].ToString());
                spellInformation[i].EnergyCost = int.Parse(spellsTable.Rows[i]["EnergyCost"].ToString());
                spellInformation[i].ManaCost = int.Parse(spellsTable.Rows[i]["ManaCost"].ToString());
                spellInformation[i].MinBase = int.Parse(spellsTable.Rows[i]["MinBase"].ToString());
                spellInformation[i].MaxBase = int.Parse(spellsTable.Rows[i]["MaxBase"].ToString());
                spellInformation[i].Diff = int.Parse(spellsTable.Rows[i]["Diff"].ToString());
                spellInformation[i].Targets = int.Parse(spellsTable.Rows[i]["Targets"].ToString());
                spellInformation[i].Dur = int.Parse(spellsTable.Rows[i]["Dur"].ToString());
                spellInformation[i].AttType = int.Parse(spellsTable.Rows[i]["AttType"].ToString());
                spellInformation[i].Magery = int.Parse(spellsTable.Rows[i]["Magery"].ToString());
                spellInformation[i].MageryLVL = int.Parse(spellsTable.Rows[i]["MageryLVL"].ToString());
                spellInformation[i].Cap = int.Parse(spellsTable.Rows[i]["Cap"].ToString());
                spellInformation[i].MaxIncLVLs = int.Parse(spellsTable.Rows[i]["MaxIncLVLs"].ToString());
                spellInformation[i].MaxInc = int.Parse(spellsTable.Rows[i]["MaxInc"].ToString());
                spellInformation[i].MinIncLVLs = int.Parse(spellsTable.Rows[i]["MinIncLVLs"].ToString());
                spellInformation[i].MinInc = int.Parse(spellsTable.Rows[i]["MinInc"].ToString());
                spellInformation[i].DurIncLVLs = int.Parse(spellsTable.Rows[i]["DurIncLVLs"].ToString());
                spellInformation[i].DurInc = int.Parse(spellsTable.Rows[i]["DurInc"].ToString());
                spellInformation[i].Abil_0 = int.Parse(spellsTable.Rows[i]["Abil-0"].ToString());
                spellInformation[i].AbilVal_0 = int.Parse(spellsTable.Rows[i]["AbilVal-0"].ToString());
                spellInformation[i].Abil_1 = int.Parse(spellsTable.Rows[i]["Abil-1"].ToString());
                spellInformation[i].AbilVal_1 = int.Parse(spellsTable.Rows[i]["AbilVal-1"].ToString());
                spellInformation[i].Abil_2 = int.Parse(spellsTable.Rows[i]["Abil-2"].ToString());
                spellInformation[i].AbilVal_2 = int.Parse(spellsTable.Rows[i]["AbilVal-2"].ToString());
                spellInformation[i].Abil_3 = int.Parse(spellsTable.Rows[i]["Abil-3"].ToString());
                spellInformation[i].AbilVal_3 = int.Parse(spellsTable.Rows[i]["AbilVal-3"].ToString());
                spellInformation[i].Abil_4 = int.Parse(spellsTable.Rows[i]["Abil-4"].ToString());
                spellInformation[i].AbilVal_4 = int.Parse(spellsTable.Rows[i]["AbilVal-4"].ToString());
                spellInformation[i].Abil_5 = int.Parse(spellsTable.Rows[i]["Abil-5"].ToString());
                spellInformation[i].AbilVal_5 = int.Parse(spellsTable.Rows[i]["AbilVal-5"].ToString());
                spellInformation[i].Abil_6 = int.Parse(spellsTable.Rows[i]["Abil-6"].ToString());
                spellInformation[i].AbilVal_6 = int.Parse(spellsTable.Rows[i]["AbilVal-6"].ToString());
                spellInformation[i].Abil_7 = int.Parse(spellsTable.Rows[i]["Abil-7"].ToString());
                spellInformation[i].AbilVal_7 = int.Parse(spellsTable.Rows[i]["AbilVal-7"].ToString());
                spellInformation[i].Abil_8 = int.Parse(spellsTable.Rows[i]["Abil-8"].ToString());
                spellInformation[i].AbilVal_8 = int.Parse(spellsTable.Rows[i]["AbilVal-8"].ToString());
                spellInformation[i].Abil_9 = int.Parse(spellsTable.Rows[i]["Abil-9"].ToString());
                spellInformation[i].AbilVal_9 = int.Parse(spellsTable.Rows[i]["AbilVal-9"].ToString());

                spellInformation[i].Learnable = int.Parse(spellsTable.Rows[i]["Learnable"].ToString());
                spellInformation[i].Learned_From = spellsTable.Rows[i]["Learned From"].ToString().Replace("\0", "");
                spellInformation[i].Casted = spellsTable.Rows[i]["Casted By"].ToString().Replace("\0", "");



            }


            return spellInformation;
        }

        public static ResourceTypes.RoomType[] LoadRoomFromDB(string iDBFile, bool write)
        {
            DatabaseUtility dbUtil = new DatabaseUtility(iDBFile);

            DataTable roomTable = dbUtil.QueryDataBaseForTableInformation("Rooms");

            ResourceTypes.RoomType[] roomInformation = new ResourceTypes.RoomType[roomTable.Rows.Count];

            for (int i = 0; i < roomTable.Rows.Count; i++)
            {
                roomInformation[i] = new ResourceTypes.RoomType();
                roomInformation[i].MapNumber = int.Parse(roomTable.Rows[i]["Map Number"].ToString());
                roomInformation[i].RoomNumber = int.Parse(roomTable.Rows[i]["Room Number"].ToString());
                roomInformation[i].RoomName = roomTable.Rows[i]["Name"].ToString().Replace("\0", "");
                roomInformation[i].ShopID = int.Parse(roomTable.Rows[i]["Shop"].ToString());
                roomInformation[i].NpcID = int.Parse(roomTable.Rows[i]["NPC"].ToString());
                roomInformation[i].CmdID = int.Parse(roomTable.Rows[i]["CMD"].ToString());
                roomInformation[i].SpellID = int.Parse(roomTable.Rows[i]["Spell"].ToString());
                roomInformation[i].LairInformation = roomTable.Rows[i]["Lair"].ToString().Replace("\0", "");
                roomInformation[i].Placed = roomTable.Rows[i]["Placed"].ToString().Replace("\0", "");
                roomInformation[i].DirectionNorth = roomTable.Rows[i]["N"].ToString().Replace("\0", "");
                roomInformation[i].DirectionSouth = roomTable.Rows[i]["S"].ToString().Replace("\0", "");
                roomInformation[i].DirectionEast = roomTable.Rows[i]["E"].ToString().Replace("\0", "");
                roomInformation[i].DirectionWest = roomTable.Rows[i]["W"].ToString().Replace("\0", "");
                roomInformation[i].DirectionNorthEast = roomTable.Rows[i]["NE"].ToString().Replace("\0", "");
                roomInformation[i].DirectionNorthWest = roomTable.Rows[i]["NW"].ToString().Replace("\0", "");
                roomInformation[i].DirectionSouthEast = roomTable.Rows[i]["SE"].ToString().Replace("\0", "");
                roomInformation[i].DirectionSouthWest = roomTable.Rows[i]["SW"].ToString().Replace("\0", "");
                roomInformation[i].DirectionUp = roomTable.Rows[i]["U"].ToString().Replace("\0", "");
                roomInformation[i].DirectionDown = roomTable.Rows[i]["D"].ToString().Replace("\0", "");
            }

            return roomInformation;
        }

        public static Dictionary<int, ResourceTypes.NpcType> LoadNpcFromDB(string iDBFile, bool write)
        {
            DatabaseUtility dbUtil = new DatabaseUtility(iDBFile);

            DataTable monsterTable = dbUtil.QueryDataBaseForTableInformation("Monsters");

            Dictionary<int, ResourceTypes.NpcType> NpcList = new Dictionary<int, ResourceTypes.NpcType>();


            for (int i = 0; i < monsterTable.Rows.Count; i++)
            {
                ResourceTypes.NpcType npcInformation = new ResourceTypes.NpcType();

                npcInformation = new ResourceTypes.NpcType();
                npcInformation.Number = int.Parse(monsterTable.Rows[i]["Number"].ToString());
                npcInformation.Name = monsterTable.Rows[i]["Name"].ToString();
                npcInformation.Weapon = int.Parse(monsterTable.Rows[i]["Weapon"].ToString());
                npcInformation.Armour = int.Parse(monsterTable.Rows[i]["ArmourClass"].ToString());
                npcInformation.DamageResist = int.Parse(monsterTable.Rows[i]["DamageResist"].ToString());
                npcInformation.Follow = int.Parse(monsterTable.Rows[i]["Follow%"].ToString());
                npcInformation.MagicResist = int.Parse(monsterTable.Rows[i]["MagicRes"].ToString());
                npcInformation.Experience = int.Parse(monsterTable.Rows[i]["EXP"].ToString());
                npcInformation.ExperienceMulti = int.Parse(monsterTable.Rows[i]["ExpMulti"].ToString());
                npcInformation.HitPoints = int.Parse(monsterTable.Rows[i]["HP"].ToString());
                npcInformation.GreetText = int.Parse(monsterTable.Rows[i]["GreetTXT"].ToString());
                npcInformation.HPRegen = int.Parse(monsterTable.Rows[i]["HPRegen"].ToString());
                npcInformation.CharmLVL = int.Parse(monsterTable.Rows[i]["CharmLVL"].ToString());
                npcInformation.Type = int.Parse(monsterTable.Rows[i]["Type"].ToString());
                npcInformation.Undead = int.Parse(monsterTable.Rows[i]["Undead"].ToString());
                npcInformation.Align = int.Parse(monsterTable.Rows[i]["Align"].ToString());
                npcInformation.RegenTime = int.Parse(monsterTable.Rows[i]["RegenTime"].ToString());
                npcInformation.Runic = int.Parse(monsterTable.Rows[i]["R"].ToString());
                npcInformation.Platinum = int.Parse(monsterTable.Rows[i]["P"].ToString());
                npcInformation.Gold = int.Parse(monsterTable.Rows[i]["G"].ToString());
                npcInformation.Silver = int.Parse(monsterTable.Rows[i]["S"].ToString());
                npcInformation.Copper = int.Parse(monsterTable.Rows[i]["C"].ToString());
                npcInformation.DeathSpell = int.Parse(monsterTable.Rows[i]["DeathSpell"].ToString());
                npcInformation.CreateSpell = int.Parse(monsterTable.Rows[i]["CreateSpell"].ToString());
                npcInformation.AttType_0 = int.Parse(monsterTable.Rows[i]["AttType-0"].ToString());
                npcInformation.AttAcc_0 = int.Parse(monsterTable.Rows[i]["AttAcc-0"].ToString());
                npcInformation.AttPercent_0 = int.Parse(monsterTable.Rows[i]["Att%-0"].ToString());
                npcInformation.AttMin_0 = int.Parse(monsterTable.Rows[i]["AttMin-0"].ToString());
                npcInformation.AttMax_0 = int.Parse(monsterTable.Rows[i]["AttMax-0"].ToString());
                npcInformation.AttEnergy_0 = int.Parse(monsterTable.Rows[i]["AttEnergy-0"].ToString());
                npcInformation.AttHitSpell_0 = int.Parse(monsterTable.Rows[i]["AttHitSpell-0"].ToString());
                npcInformation.AttType_1 = int.Parse(monsterTable.Rows[i]["AttType-1"].ToString());
                npcInformation.AttAcc_1 = int.Parse(monsterTable.Rows[i]["AttAcc-1"].ToString());
                npcInformation.AttPercent_1 = int.Parse(monsterTable.Rows[i]["Att%-1"].ToString());
                npcInformation.AttMin_1 = int.Parse(monsterTable.Rows[i]["AttMin-1"].ToString());
                npcInformation.AttMax_1 = int.Parse(monsterTable.Rows[i]["AttMax-1"].ToString());
                npcInformation.AttEnergy_1 = int.Parse(monsterTable.Rows[i]["AttEnergy-1"].ToString());
                npcInformation.AttHitSpell_1 = int.Parse(monsterTable.Rows[i]["AttHitSpell-1"].ToString());
                npcInformation.AttType_2 = int.Parse(monsterTable.Rows[i]["AttType-2"].ToString());
                npcInformation.AttAcc_2 = int.Parse(monsterTable.Rows[i]["AttAcc-2"].ToString());
                npcInformation.AttPercent_2 = int.Parse(monsterTable.Rows[i]["Att%-2"].ToString());
                npcInformation.AttMin_2 = int.Parse(monsterTable.Rows[i]["AttMin-2"].ToString());
                npcInformation.AttMax_2 = int.Parse(monsterTable.Rows[i]["AttMax-2"].ToString());
                npcInformation.AttEnergy_2 = int.Parse(monsterTable.Rows[i]["AttEnergy-2"].ToString());
                npcInformation.AttHitSpell_2 = int.Parse(monsterTable.Rows[i]["AttHitSpell-2"].ToString());
                npcInformation.AttType_3 = int.Parse(monsterTable.Rows[i]["AttType-3"].ToString());
                npcInformation.AttAcc_3 = int.Parse(monsterTable.Rows[i]["AttAcc-3"].ToString());
                npcInformation.AttPercent_3 = int.Parse(monsterTable.Rows[i]["Att%-3"].ToString());
                npcInformation.AttMin_3 = int.Parse(monsterTable.Rows[i]["AttMin-3"].ToString());
                npcInformation.AttMax_3 = int.Parse(monsterTable.Rows[i]["AttMax-3"].ToString());
                npcInformation.AttEnergy_3 = int.Parse(monsterTable.Rows[i]["AttEnergy-3"].ToString());
                npcInformation.AttHitSpell_3 = int.Parse(monsterTable.Rows[i]["AttHitSpell-3"].ToString());
                npcInformation.AttType_4 = int.Parse(monsterTable.Rows[i]["AttType-4"].ToString());
                npcInformation.AttAcc_4 = int.Parse(monsterTable.Rows[i]["AttAcc-4"].ToString());
                npcInformation.AttPercent_4 = int.Parse(monsterTable.Rows[i]["Att%-4"].ToString());
                npcInformation.AttMin_4 = int.Parse(monsterTable.Rows[i]["AttMin-4"].ToString());
                npcInformation.AttMax_4 = int.Parse(monsterTable.Rows[i]["AttMax-4"].ToString());
                npcInformation.AttEnergy_4 = int.Parse(monsterTable.Rows[i]["AttEnergy-4"].ToString());
                npcInformation.AttHitSpell_4 = int.Parse(monsterTable.Rows[i]["AttHitSpell-4"].ToString());

                npcInformation.MidSpell_0 = int.Parse(monsterTable.Rows[i]["MidSpell-0"].ToString());
                npcInformation.MidSpellPercent_0 = int.Parse(monsterTable.Rows[i]["MidSpell-0"].ToString());
                npcInformation.MidSpellLVL_0 = int.Parse(monsterTable.Rows[i]["MidSpell-0"].ToString());

                npcInformation.MidSpell_1 = int.Parse(monsterTable.Rows[i]["MidSpell-1"].ToString());
                npcInformation.MidSpellPercent_1 = int.Parse(monsterTable.Rows[i]["MidSpell-1"].ToString());
                npcInformation.MidSpellLVL_1 = int.Parse(monsterTable.Rows[i]["MidSpell-1"].ToString());
                npcInformation.MidSpell_2 = int.Parse(monsterTable.Rows[i]["MidSpell-2"].ToString());
                npcInformation.MidSpellPercent_2 = int.Parse(monsterTable.Rows[i]["MidSpell-2"].ToString());
                npcInformation.MidSpellLVL_2 = int.Parse(monsterTable.Rows[i]["MidSpell-2"].ToString());
                npcInformation.MidSpell_3 = int.Parse(monsterTable.Rows[i]["MidSpell-3"].ToString());
                npcInformation.MidSpellPercent_3 = int.Parse(monsterTable.Rows[i]["MidSpell-3"].ToString());
                npcInformation.MidSpellLVL_3 = int.Parse(monsterTable.Rows[i]["MidSpell-3"].ToString());
                npcInformation.MidSpell_4 = int.Parse(monsterTable.Rows[i]["MidSpell-4"].ToString());
                npcInformation.MidSpellPercent_4 = int.Parse(monsterTable.Rows[i]["MidSpell-4"].ToString());
                npcInformation.MidSpellLVL_4 = int.Parse(monsterTable.Rows[i]["MidSpell-4"].ToString());
                npcInformation.DropItem_0 = int.Parse(monsterTable.Rows[i]["DropItem-0"].ToString());
                npcInformation.DropItemPercent_0 = int.Parse(monsterTable.Rows[i]["DropItem%-0"].ToString());
                npcInformation.DropItem_1 = int.Parse(monsterTable.Rows[i]["DropItem-1"].ToString());
                npcInformation.DropItemPercent_1 = int.Parse(monsterTable.Rows[i]["DropItem%-1"].ToString());
                npcInformation.DropItem_2 = int.Parse(monsterTable.Rows[i]["DropItem-2"].ToString());
                npcInformation.DropItemPercent_2 = int.Parse(monsterTable.Rows[i]["DropItem%-2"].ToString());
                npcInformation.DropItem_3 = int.Parse(monsterTable.Rows[i]["DropItem-3"].ToString());
                npcInformation.DropItemPercent_3 = int.Parse(monsterTable.Rows[i]["DropItem%-3"].ToString());
                npcInformation.DropItem_4 = int.Parse(monsterTable.Rows[i]["DropItem-4"].ToString());
                npcInformation.DropItemPercent_4 = int.Parse(monsterTable.Rows[i]["DropItem%-4"].ToString());
                npcInformation.DropItem_5 = int.Parse(monsterTable.Rows[i]["DropItem-5"].ToString());
                npcInformation.DropItemPercent_5 = int.Parse(monsterTable.Rows[i]["DropItem%-5"].ToString());
                npcInformation.DropItem_6 = int.Parse(monsterTable.Rows[i]["DropItem-6"].ToString());
                npcInformation.DropItemPercent_6 = int.Parse(monsterTable.Rows[i]["DropItem%-6"].ToString());
                npcInformation.DropItem_7 = int.Parse(monsterTable.Rows[i]["DropItem-7"].ToString());
                npcInformation.DropItemPercent_7 = int.Parse(monsterTable.Rows[i]["DropItem%-7"].ToString());
                npcInformation.DropItem_8 = int.Parse(monsterTable.Rows[i]["DropItem-8"].ToString());
                npcInformation.DropItemPercent_8 = int.Parse(monsterTable.Rows[i]["DropItem%-8"].ToString());
                npcInformation.DropItem_9 = int.Parse(monsterTable.Rows[i]["DropItem-9"].ToString());
                npcInformation.DropItemPercent_9 = int.Parse(monsterTable.Rows[i]["DropItem%-9"].ToString());
                npcInformation.Ability_0 = int.Parse(monsterTable.Rows[i]["Abil-0"].ToString());
                npcInformation.AbilityValue_0 = int.Parse(monsterTable.Rows[i]["AbilVal-0"].ToString());
                npcInformation.Ability_1 = int.Parse(monsterTable.Rows[i]["Abil-1"].ToString());
                npcInformation.AbilityValue_1 = int.Parse(monsterTable.Rows[i]["AbilVal-1"].ToString());
                npcInformation.Ability_2 = int.Parse(monsterTable.Rows[i]["Abil-2"].ToString());
                npcInformation.AbilityValue_2 = int.Parse(monsterTable.Rows[i]["AbilVal-2"].ToString());
                npcInformation.Ability_3 = int.Parse(monsterTable.Rows[i]["Abil-3"].ToString());
                npcInformation.AbilityValue_3 = int.Parse(monsterTable.Rows[i]["AbilVal-3"].ToString());
                npcInformation.Ability_4 = int.Parse(monsterTable.Rows[i]["Abil-4"].ToString());
                npcInformation.AbilityValue_4 = int.Parse(monsterTable.Rows[i]["AbilVal-4"].ToString());
                npcInformation.Ability_5 = int.Parse(monsterTable.Rows[i]["Abil-5"].ToString());
                npcInformation.AbilityValue_5 = int.Parse(monsterTable.Rows[i]["AbilVal-5"].ToString());
                npcInformation.Ability_6 = int.Parse(monsterTable.Rows[i]["Abil-6"].ToString());
                npcInformation.AbilityValue_6 = int.Parse(monsterTable.Rows[i]["AbilVal-6"].ToString());
                npcInformation.Ability_7 = int.Parse(monsterTable.Rows[i]["Abil-7"].ToString());
                npcInformation.AbilityValue_7 = int.Parse(monsterTable.Rows[i]["AbilVal-7"].ToString());
                npcInformation.Ability_8 = int.Parse(monsterTable.Rows[i]["Abil-8"].ToString());
                npcInformation.AbilityValue_8 = int.Parse(monsterTable.Rows[i]["AbilVal-8"].ToString());
                npcInformation.Ability_9 = int.Parse(monsterTable.Rows[i]["Abil-9"].ToString());
                npcInformation.AbilityValue_9 = int.Parse(monsterTable.Rows[i]["AbilVal-9"].ToString());
                npcInformation.InGame = int.Parse(monsterTable.Rows[i]["In Game"].ToString());
                npcInformation.Summoned = "";

                if (npcInformation.DropItem_0 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_0));
                }
                if (npcInformation.DropItem_1 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_1));
                }
                if (npcInformation.DropItem_2 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_2));
                }
                if (npcInformation.DropItem_3 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_3));
                }
                if (npcInformation.DropItem_4 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_4));
                }

                if (npcInformation.DropItem_5 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_5));
                }
                if (npcInformation.DropItem_6 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_6));
                }
                if (npcInformation.DropItem_7 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_7));
                }
                if (npcInformation.DropItem_8 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_8));
                }

                if (npcInformation.DropItem_9 != 0)
                {
                    npcInformation.DroppedItems.Add(GameResources.FindItem(npcInformation.DropItem_9));
                }

                if (npcInformation.Ability_0 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_0, npcInformation.AbilityValue_0));
                }

                if (npcInformation.Ability_1 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_1, npcInformation.AbilityValue_1));
                }

                if (npcInformation.Ability_2 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_2, npcInformation.AbilityValue_2));
                }

                if (npcInformation.Ability_3 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_3, npcInformation.AbilityValue_3));
                }

                if (npcInformation.Ability_4 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_4, npcInformation.AbilityValue_4));
                }

                if (npcInformation.Ability_5 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_5, npcInformation.AbilityValue_5));
                }

                if (npcInformation.Ability_6 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_6, npcInformation.AbilityValue_6));
                }

                if (npcInformation.Ability_7 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_7, npcInformation.AbilityValue_7));
                }

                if (npcInformation.Ability_8 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_8, npcInformation.AbilityValue_8));
                }

                if (npcInformation.Ability_9 != 0)
                {
                    npcInformation.AbilityList.Add(FindAbility(npcInformation.Ability_9, npcInformation.AbilityValue_9));
                }

                if (npcInformation.MidSpell_0 != 0)
                {
                    npcInformation.SpellList.Add(GameResources.FindSpell(npcInformation.MidSpell_0));
                }

                if (npcInformation.MidSpell_1 != 0)
                {
                    npcInformation.SpellList.Add(GameResources.FindSpell(npcInformation.MidSpell_1));
                }

                if (npcInformation.MidSpell_2 != 0)
                {
                    npcInformation.SpellList.Add(GameResources.FindSpell(npcInformation.MidSpell_2));
                }

                if (npcInformation.MidSpell_3 != 0)
                {
                    npcInformation.SpellList.Add(GameResources.FindSpell(npcInformation.MidSpell_3));
                }

                if (npcInformation.MidSpell_4 != 0)
                {
                    npcInformation.SpellList.Add(GameResources.FindSpell(npcInformation.MidSpell_4));
                }

                if (npcInformation.DeathSpell != 0)
                {
                    npcInformation.SpellList.Add(GameResources.FindSpell(npcInformation.DeathSpell));
                }


                npcInformation.SpellMonsterCast = GameResources.BuildSpellList(npcInformation);

                NpcList.Add(npcInformation.Number, npcInformation);
            }

            return NpcList;
        }

        public static ResourceTypes.AbilityType FindAbility(int abil, int value)
        {
            ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

            iAbil.AbilityID = abil;
            iAbil.AbilityValue = value;
            iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);

            return iAbil;
        }
        public static Dictionary<int, ResourceTypes.ItemType> LoadItemFromDB(string iDBFile, bool write)
        {

            DatabaseUtility dbUtil = new DatabaseUtility(iDBFile);

            DataTable itemTable = dbUtil.QueryDataBaseForTableInformation("Items");

            Dictionary<int, ResourceTypes.ItemType> ItemList = new Dictionary<int, ResourceTypes.ItemType>();


            for (int i = 0; i < itemTable.Rows.Count; i++)
            {
                ResourceTypes.ItemType itemInformation = new ResourceTypes.ItemType();

                itemInformation = new ResourceTypes.ItemType();
                itemInformation.Number = int.Parse(itemTable.Rows[i]["Number"].ToString());
                itemInformation.Name = itemTable.Rows[i]["Name"].ToString();
                itemInformation.Limit = int.Parse(itemTable.Rows[i]["Limit"].ToString());
                itemInformation.Encum = int.Parse(itemTable.Rows[i]["Encum"].ToString());
                itemInformation.Item_Type = int.Parse(itemTable.Rows[i]["ItemType"].ToString());
                itemInformation.UseCount = int.Parse(itemTable.Rows[i]["UseCount"].ToString());
                itemInformation.Price = int.Parse(itemTable.Rows[i]["Price"].ToString());
                itemInformation.Currency = int.Parse(itemTable.Rows[i]["Currency"].ToString());
                itemInformation.Min = int.Parse(itemTable.Rows[i]["Min"].ToString());
                itemInformation.Max = int.Parse(itemTable.Rows[i]["Max"].ToString());
                itemInformation.ArmourClass = int.Parse(itemTable.Rows[i]["ArmourClass"].ToString());
                itemInformation.DamageResist = int.Parse(itemTable.Rows[i]["DamageResist"].ToString());
                itemInformation.WeaponType = int.Parse(itemTable.Rows[i]["WeaponType"].ToString());
                itemInformation.ArmourType = int.Parse(itemTable.Rows[i]["ArmourType"].ToString());
                itemInformation.Worn = int.Parse(itemTable.Rows[i]["Worn"].ToString());
                itemInformation.Accuracy = int.Parse(itemTable.Rows[i]["Accy"].ToString());
                itemInformation.Gettable = int.Parse(itemTable.Rows[i]["Gettable"].ToString());
                itemInformation.StrRequired = int.Parse(itemTable.Rows[i]["StrReq"].ToString());
                itemInformation.Speed = int.Parse(itemTable.Rows[i]["Speed"].ToString());
                itemInformation.NotDroppable = int.Parse(itemTable.Rows[i]["Not Droppable"].ToString());
                itemInformation.DestoryOnDeath = int.Parse(itemTable.Rows[i]["Destroy On Death"].ToString());
                itemInformation.RetainAfterUses = int.Parse(itemTable.Rows[i]["Retain After Uses"].ToString());
                itemInformation.ClassRestriction_0 = int.Parse(itemTable.Rows[i]["ClassRest-0"].ToString());
                itemInformation.ClassRestriction_1 = int.Parse(itemTable.Rows[i]["ClassRest-1"].ToString());
                itemInformation.ClassRestriction_2 = int.Parse(itemTable.Rows[i]["ClassRest-2"].ToString());
                itemInformation.ClassRestriction_3 = int.Parse(itemTable.Rows[i]["ClassRest-3"].ToString());
                itemInformation.ClassRestriction_4 = int.Parse(itemTable.Rows[i]["ClassRest-4"].ToString());
                itemInformation.ClassRestriction_5 = int.Parse(itemTable.Rows[i]["ClassRest-5"].ToString());
                itemInformation.ClassRestriction_6 = int.Parse(itemTable.Rows[i]["ClassRest-6"].ToString());
                itemInformation.ClassRestriction_7 = int.Parse(itemTable.Rows[i]["ClassRest-7"].ToString());
                itemInformation.ClassRestriction_8 = int.Parse(itemTable.Rows[i]["ClassRest-8"].ToString());
                itemInformation.ClassRestriction_9 = int.Parse(itemTable.Rows[i]["ClassRest-9"].ToString());
                itemInformation.RaceRestriction_0 = int.Parse(itemTable.Rows[i]["RaceRest-0"].ToString());
                itemInformation.RaceRestriction_1 = int.Parse(itemTable.Rows[i]["RaceRest-1"].ToString());
                itemInformation.RaceRestriction_2 = int.Parse(itemTable.Rows[i]["RaceRest-2"].ToString());
                itemInformation.RaceRestriction_3 = int.Parse(itemTable.Rows[i]["RaceRest-3"].ToString());
                itemInformation.RaceRestriction_4 = int.Parse(itemTable.Rows[i]["RaceRest-4"].ToString());
                itemInformation.RaceRestriction_5 = int.Parse(itemTable.Rows[i]["RaceRest-5"].ToString());
                itemInformation.RaceRestriction_6 = int.Parse(itemTable.Rows[i]["RaceRest-6"].ToString());
                itemInformation.RaceRestriction_7 = int.Parse(itemTable.Rows[i]["RaceRest-7"].ToString());
                itemInformation.RaceRestriction_8 = int.Parse(itemTable.Rows[i]["RaceRest-8"].ToString());
                itemInformation.RaceRestriction_9 = int.Parse(itemTable.Rows[i]["RaceRest-9"].ToString());
                itemInformation.NegateSpell_0 = int.Parse(itemTable.Rows[i]["NegateSpell-0"].ToString());
                itemInformation.NegateSpell_1 = int.Parse(itemTable.Rows[i]["NegateSpell-1"].ToString());
                itemInformation.NegateSpell_2 = int.Parse(itemTable.Rows[i]["NegateSpell-2"].ToString());
                itemInformation.NegateSpell_3 = int.Parse(itemTable.Rows[i]["NegateSpell-3"].ToString());
                itemInformation.NegateSpell_4 = int.Parse(itemTable.Rows[i]["NegateSpell-4"].ToString());
                itemInformation.NegateSpell_5 = int.Parse(itemTable.Rows[i]["NegateSpell-5"].ToString());
                itemInformation.NegateSpell_6 = int.Parse(itemTable.Rows[i]["NegateSpell-6"].ToString());
                itemInformation.NegateSpell_7 = int.Parse(itemTable.Rows[i]["NegateSpell-7"].ToString());
                itemInformation.NegateSpell_8 = int.Parse(itemTable.Rows[i]["NegateSpell-8"].ToString());
                itemInformation.NegateSpell_9 = int.Parse(itemTable.Rows[i]["NegateSpell-9"].ToString());
                itemInformation.Ability_0 = int.Parse(itemTable.Rows[i]["Abil-0"].ToString());
                itemInformation.AbilityValue_0 = int.Parse(itemTable.Rows[i]["AbilVal-0"].ToString());
                itemInformation.Ability_1 = int.Parse(itemTable.Rows[i]["Abil-1"].ToString());
                itemInformation.AbilityValue_1 = int.Parse(itemTable.Rows[i]["AbilVal-1"].ToString());
                itemInformation.Ability_2 = int.Parse(itemTable.Rows[i]["Abil-2"].ToString());
                itemInformation.AbilityValue_2 = int.Parse(itemTable.Rows[i]["AbilVal-2"].ToString());
                itemInformation.Ability_3 = int.Parse(itemTable.Rows[i]["Abil-3"].ToString());
                itemInformation.AbilityValue_3 = int.Parse(itemTable.Rows[i]["AbilVal-3"].ToString());
                itemInformation.Ability_4 = int.Parse(itemTable.Rows[i]["Abil-4"].ToString());
                itemInformation.AbilityValue_4 = int.Parse(itemTable.Rows[i]["AbilVal-4"].ToString());
                itemInformation.Ability_5 = int.Parse(itemTable.Rows[i]["Abil-5"].ToString());
                itemInformation.AbilityValue_5 = int.Parse(itemTable.Rows[i]["AbilVal-5"].ToString());
                itemInformation.Ability_6 = int.Parse(itemTable.Rows[i]["Abil-6"].ToString());
                itemInformation.AbilityValue_6 = int.Parse(itemTable.Rows[i]["AbilVal-6"].ToString());
                itemInformation.Ability_7 = int.Parse(itemTable.Rows[i]["Abil-7"].ToString());
                itemInformation.AbilityValue_7 = int.Parse(itemTable.Rows[i]["AbilVal-7"].ToString());
                itemInformation.Ability_8 = int.Parse(itemTable.Rows[i]["Abil-8"].ToString());
                itemInformation.AbilityValue_8 = int.Parse(itemTable.Rows[i]["AbilVal-8"].ToString());
                itemInformation.Ability_9 = int.Parse(itemTable.Rows[i]["Abil-9"].ToString());
                itemInformation.AbilityValue_9 = int.Parse(itemTable.Rows[i]["AbilVal-9"].ToString());
                itemInformation.Ability_10 = int.Parse(itemTable.Rows[i]["Abil-10"].ToString());
                itemInformation.AbilityValue_10 = int.Parse(itemTable.Rows[i]["AbilVal-10"].ToString());
                itemInformation.Ability_11 = int.Parse(itemTable.Rows[i]["Abil-11"].ToString());
                itemInformation.AbilityValue_11 = int.Parse(itemTable.Rows[i]["AbilVal-11"].ToString());
                itemInformation.Ability_12 = int.Parse(itemTable.Rows[i]["Abil-12"].ToString());
                itemInformation.AbilityValue_12 = int.Parse(itemTable.Rows[i]["AbilVal-12"].ToString());
                itemInformation.Ability_13 = int.Parse(itemTable.Rows[i]["Abil-13"].ToString());
                itemInformation.AbilityValue_13 = int.Parse(itemTable.Rows[i]["AbilVal-13"].ToString());
                itemInformation.Ability_14 = int.Parse(itemTable.Rows[i]["Abil-14"].ToString());
                itemInformation.AbilityValue_14 = int.Parse(itemTable.Rows[i]["AbilVal-14"].ToString());
                itemInformation.Ability_15 = int.Parse(itemTable.Rows[i]["Abil-15"].ToString());
                itemInformation.AbilityValue_15 = int.Parse(itemTable.Rows[i]["AbilVal-15"].ToString());
                itemInformation.Ability_16 = int.Parse(itemTable.Rows[i]["Abil-16"].ToString());
                itemInformation.AbilityValue_16 = int.Parse(itemTable.Rows[i]["AbilVal-16"].ToString());
                itemInformation.Ability_17 = int.Parse(itemTable.Rows[i]["Abil-17"].ToString());
                itemInformation.AbilityValue_17 = int.Parse(itemTable.Rows[i]["AbilVal-17"].ToString());
                itemInformation.Ability_18 = int.Parse(itemTable.Rows[i]["Abil-18"].ToString());
                itemInformation.AbilityValue_18 = int.Parse(itemTable.Rows[i]["AbilVal-18"].ToString());
                itemInformation.Ability_19 = int.Parse(itemTable.Rows[i]["Abil-19"].ToString());
                itemInformation.AbilityValue_19 = int.Parse(itemTable.Rows[i]["AbilVal-19"].ToString());
                itemInformation.InGame = int.Parse(itemTable.Rows[i]["In Game"].ToString());
                itemInformation.ObtainedFrom = itemTable.Rows[i]["Obtained From"].ToString().Replace("\0", "");


                if (itemInformation.Ability_0 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_0;
                    iAbil.AbilityValue = itemInformation.AbilityValue_0;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_1 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_1;
                    iAbil.AbilityValue = itemInformation.AbilityValue_1;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_2 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_2;
                    iAbil.AbilityValue = itemInformation.AbilityValue_2;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }

                if (itemInformation.Ability_3 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_3;
                    iAbil.AbilityValue = itemInformation.AbilityValue_3;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_4 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_4;
                    iAbil.AbilityValue = itemInformation.AbilityValue_4;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_5 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_5;
                    iAbil.AbilityValue = itemInformation.AbilityValue_5;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_6 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_6;
                    iAbil.AbilityValue = itemInformation.AbilityValue_6;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_7 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_7;
                    iAbil.AbilityValue = itemInformation.AbilityValue_7;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_8 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_8;
                    iAbil.AbilityValue = itemInformation.AbilityValue_8;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_9 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_9;
                    iAbil.AbilityValue = itemInformation.AbilityValue_9;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_10 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_10;
                    iAbil.AbilityValue = itemInformation.AbilityValue_10;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_11 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_11;
                    iAbil.AbilityValue = itemInformation.AbilityValue_11;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_12 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_12;
                    iAbil.AbilityValue = itemInformation.AbilityValue_12;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_13 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_13;
                    iAbil.AbilityValue = itemInformation.AbilityValue_13;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_14 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_14;
                    iAbil.AbilityValue = itemInformation.AbilityValue_14;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_15 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_15;
                    iAbil.AbilityValue = itemInformation.AbilityValue_15;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_16 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_16;
                    iAbil.AbilityValue = itemInformation.AbilityValue_16;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_17 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_17;
                    iAbil.AbilityValue = itemInformation.AbilityValue_17;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
                if (itemInformation.Ability_18 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_18;
                    iAbil.AbilityValue = itemInformation.AbilityValue_18;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }

                if (itemInformation.Ability_19 != 0)
                {
                    ResourceTypes.AbilityType iAbil = new ResourceTypes.AbilityType();

                    iAbil.AbilityID = itemInformation.Ability_19;
                    iAbil.AbilityValue = itemInformation.AbilityValue_19;
                    iAbil.AbilityName = GameResources.FindAbility(iAbil.AbilityID);
                    itemInformation.Abilities.Add(iAbil);
                }
               
                
                ItemList.Add(itemInformation.Number, itemInformation);

            }


            return ItemList;
        }

        //public static Dictionary<int, ResourceTypes.ItemType> LoadItemFromXML(string itemFile)
        //{
        //    List<ResourceTypes.ItemType> iList = new List<ResourceTypes.ItemType>();

        //    Dictionary<int, ResourceTypes.ItemType> ItemList = null;

        //    XMLUtility.ReadFromXML(out iList, itemFile);

        //    ItemList = new Dictionary<int, ResourceTypes.ItemType>();

        //    int i = 0;

        //    foreach (ResourceTypes.ItemType item in iList)
        //    {
        //        ItemList.Add(item.Number, item);
        //    }

        //    return ItemList;
        //}

      

        //public static void WriteToXML<T>(T iOutput, String iFileName)
        //{
        //    XMLUtility.WriteToXML(iOutput, iFileName);
        //}

    }
}
